Skip to content

test: cover lexer errors and token display#45

Merged
xmnlab merged 2 commits intoarxlang:mainfrom
omsherikar:test/lexer-issue-41
Apr 6, 2026
Merged

test: cover lexer errors and token display#45
xmnlab merged 2 commits intoarxlang:mainfrom
omsherikar:test/lexer-issue-41

Conversation

@omsherikar
Copy link
Copy Markdown
Contributor

@omsherikar omsherikar commented Apr 5, 2026

Bring src/arx/lexer.py to full line coverage: Token, TokenList, LexerError, docstrings, escapes, and numeric edge cases.

Solves #41

Bring src/arx/lexer.py to full line coverage: Token, TokenList, LexerError, docstrings, escapes, and numeric edge cases.
Copilot AI review requested due to automatic review settings April 5, 2026 18:33
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR expands tests/test_lexer.py to drive src/arx/lexer.py toward full line coverage by exercising previously untested branches and error paths (Token/TokenList helpers, LexerError formatting, docstring parsing, numeric edge cases, and string/char literal escapes).

Changes:

  • Add unit tests for Token.__hash__, Token.get_display_value(), and TokenList iteration behavior.
  • Add unit tests validating LexerError message formatting and location propagation.
  • Add lexer tests for false, and/or operators, lone . handling, multiple-decimal rejection, docstring delimiter/termination cases, and quoted literal escape/error cases.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

"""
title: String literals honor common backslash escapes and pass-through.
"""
ArxIO.string_to_buffer('"line\\n\\t\\\\\\"end"\n')
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test_lexer_string_escape_sequences builds the input string with too many backslashes (e.g., \\n/\\t and the ...\\\"end... segment). With the current lexer escape handling, this will not produce a newline/tab and will likely terminate the string before end, causing the assertion to fail. Update the test input so the buffer contains the intended source text: \n and \t (single backslash escapes) and \\\" (a literal backslash followed by an escaped quote), and end the buffer with a real newline (\n) rather than a literal backslash-n sequence.

Suggested change
ArxIO.string_to_buffer('"line\\n\\t\\\\\\"end"\n')
ArxIO.string_to_buffer('"line\n\t\\\"end"\n')

Copilot uses AI. Check for mistakes.
@xmnlab xmnlab merged commit e97aad4 into arxlang:main Apr 6, 2026
9 checks passed
@xmnlab
Copy link
Copy Markdown
Contributor

xmnlab commented Apr 6, 2026

Thanks @omsherikar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants